#include "VTTErrorManager.h"

using std::stack;
using std::string;

VTTErrorManager *VTTErrorManager::errorManager = 0;

/**
  *	Constructs a new instance of the VTTErrorManager class
  */
VTTErrorManager::VTTErrorManager( void )
{

}

/**
  *	Destroys the instance
  */
VTTErrorManager::~VTTErrorManager( void )
{

}

/**
  *	Returns the only instance of the VTTErrorManager class.
  *
  * @return the only instance of the VTTErrorManager class
  */
VTTErrorManager *VTTErrorManager::Get( void )
{
	if (!errorManager)
		errorManager = new VTTErrorManager();

	return errorManager;
}

/**
  *	Flushes the stack, which means that all error messages are removed.
  */
void VTTErrorManager::flush()
{
	while (!mErrorMessageStack.empty())
	{
		mErrorMessageStack.pop();
	}
}

/**
  *	Pushes an error message onto the stack.
  *
  * @param errorMessage error message that is pushed onto the stack
  */
void VTTErrorManager::pushErrorMessage( const string &errorMessage )
{
	mErrorMessageStack.push( errorMessage );
}

/**
  *	Removes the top level message from the stack and returns it.
  *
  * @return top level message from the stack
  */
string VTTErrorManager::popErrorMessage( void )
{
	if (!mErrorMessageStack.empty())
	{
		string return_value = mErrorMessageStack.top();
		mErrorMessageStack.pop();
		
		return return_value;
	}

	return "";
}